package reflect;

import reflect.annotations.AutoRunMethod;

import java.lang.reflect.Method;

/**
 * 反射机制访问注解2
 * 判断一个方法是否被指定注解标注
 */
public class ReflectDemo8 {
    public static void main(String[] args) throws Exception {
        //需求:查看Person类的sayHi方法是否被注解@AutoRunMethod标注了
        Class cls = Class.forName("reflect.Person");

        Method method = cls.getDeclaredMethod("sayHi");
        boolean mark = method.isAnnotationPresent(AutoRunMethod.class);
        System.out.println(
                method.getName()+"()是否被注解@AutoRunMethod标注了:"+mark
        );

    }
}





